# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=jstillery
pkgver=65.512e9af
pkgrel=1
groups=('blackarch' 'blackarch-webapp')
pkgdesc='Advanced JavaScript Deobfuscation via Partial Evaluation.'
url='https://github.com/mindedsecurity/JStillery'
arch=('any')
license=('GPL3')
depends=('nodejs')
makedepends=('git' 'npm')
source=("$pkgname::git+https://github.com/mindedsecurity/JStillery.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  npm install --user root -g --prefix "$pkgdir/usr"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  rm README.md LICENSE

  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
exec node /usr/share/$pkgname/jstillery_cli.js "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

